package com.bbu.javaexam.service.impl;

import com.bbu.javaexam.domain.FillQuestion;
import com.bbu.javaexam.domain.JudgeQuestion;
import com.bbu.javaexam.domain.MultiQuestion;
import com.bbu.javaexam.service.FillQuestionService;
import com.bbu.javaexam.service.JudgeQuestionService;
import com.bbu.javaexam.service.MultiQuestionService;
import com.bbu.javaexam.service.SelectQuestionsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Alex
 * @version 1.0.0
 * @ClassName SelectQuestionsServiceImpl.java
 * @Description TODO
 * @createTime 2022年02月23日 10:21:00
 */
@Service
@Slf4j
public class SelectQuestionsServiceImpl implements SelectQuestionsService {

    @Autowired
    private FillQuestionService fillQuestionService;

    @Autowired
    private JudgeQuestionService judgeQuestionService;

    @Autowired
    private MultiQuestionService multiQuestionService;

    @Override
    public Object selectQuestion(Integer questionId, String type) {
        if ("1".equals(type)) {
            MultiQuestion multiQuestion = multiQuestionService.getById(questionId);
            if (null != multiQuestion) {
                return multiQuestion;
            }
        } else if ("2".equals(type)) {
            JudgeQuestion judgeQuestion = judgeQuestionService.getById(questionId);
            if (null != judgeQuestion) {
                return judgeQuestion;
            }
        } else if ("3".equals(type)) {
            FillQuestion fillQuestion = fillQuestionService.getById(questionId);
            if (null != fillQuestion) {
                return fillQuestion;
            }
        }
        return null;
    }
}
